%option noyywrap
%option prefix="exp"

%{
#include <stdio.h>
#include <string.h>
#include "exp.tab.hpp"

char* exp_input_ptr;

#define YY_INPUT(buf,result,max_size) \
    { \
    int c = (*exp_input_ptr != '\0') ? *(exp_input_ptr++) : EOF; \
    result = (c == EOF) ? YY_NULL : (buf[0] = c, 1); \
    }

int leq(float fl1, float fl2) { return fl1 <= fl2; }
int geq(float fl1, float fl2) { return fl1 >= fl2; }
int lt(float fl1, float fl2) { return fl1 < fl2; }
int gt(float fl1, float fl2) { return fl1 > fl2; }
int eq(float fl1, float fl2) { return fl1 == fl2; }

int and(int i1, int i2) { return i1 && i2; }
int or(int i1, int i2) { return i1 || i2; }
%}

%%
\(                      return PO;
\)                      return PC;
and                     explval.comp2 = &and; return BOP;
or                      explval.comp2 = &or; return BOP;
not                     return NOT;
\<|lt                   explval.boop2 = &lt; return COP;
\>|gt                   explval.boop2 = &gt; return COP;
\<\=|leq                explval.boop2 = &leq; return COP;
\>\=|geq                explval.boop2 = &geq; return COP;
\=\=|eq                 explval.boop2 = &eq; return COP;
true|false              if(strncmp(yytext,"true",4)==0) { explval.number=1; } else { explval.number=0; }; return BOOL;
[-+]?[0-9]*\.?[0-9]+	explval.number=atof(yytext); return NUMBER;
\n                  	/* ignore end of line */;
%%
